package com.siyu.predict.rsvrjob.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.siyu.predict.rsvrjob.domain.RsvrJob;
import com.siyu.predict.rsvrjob.service.IRsvrJobService;

/**
 * 水库定时任务配置时间Controller
 *
 * @author hrhy
 * @date 2024-08-19
 */
@RestController
@RequestMapping("/predict/RsvrJob")
public class RsvrJobController extends BaseController {
    @Autowired
    private IRsvrJobService rsvrJobService;

    /**
     * 查询水库定时任务配置时间列表
     */
    @GetMapping("/list")
    public TableDataInfo list(RsvrJob rsvrJob) {
        startPage();
        List<RsvrJob> list = rsvrJobService.selectRsvrJobList(rsvrJob);
        return getDataTable(list);
    }

    /**
     * 导出水库定时任务配置时间列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, RsvrJob rsvrJob) {
        List<RsvrJob> list = rsvrJobService.selectRsvrJobList(rsvrJob);
        ExcelUtil<RsvrJob> util = new ExcelUtil<RsvrJob>(RsvrJob.class);
        util.exportExcel(response, list, "水库定时任务配置时间数据");
    }

    /**
     * 获取水库定时任务配置时间详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(rsvrJobService.selectRsvrJobById(id));
    }

    /**
     * 新增水库定时任务配置时间
     */
    @PostMapping
    public AjaxResult add(@RequestBody RsvrJob rsvrJob) {
        return toAjax(rsvrJobService.insertRsvrJob(rsvrJob));
    }

    /**
     * 修改水库定时任务配置时间
     */
    @PutMapping
    public AjaxResult edit(@RequestBody RsvrJob rsvrJob) {
        return toAjax(rsvrJobService.updateRsvrJob(rsvrJob));
    }

    /**
     * 删除水库定时任务配置时间
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(rsvrJobService.deleteRsvrJobByIds(ids));
    }
}
